<?php

namespace App\Http\Controllers\Stats\Game;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Resources\Common\DatasResource;
use App\Services\Stats\Game\GameService;

class GameController extends Controller
{

    /**
     * 导出数据
     */
    public function export(Request $request)
    {
        GameService::create()->getList($request, true);
    }

    /**
     * 导出数据【USD】
     */
    public function exportUsd(Request $request)
    {
        GameService::create()->getUsd($request, true);
    }

    /**
     * 获取游戏统计列表
     */
    public function getList(Request $request)
    {
        list ($collection, $total, $stats) = GameService::create()->getList($request);

        return DatasResource::make($collection)->setPaginateTotal($total)->setAttribute('stats', $stats);
    }

    /**
     * 获取游戏统计USD
     */
    public function getUsd(Request $request)
    {
        list ($collection, $stats) = GameService::create()->getUsd($request);

        return DatasResource::make($collection)->setAttribute('stats', $stats);
    }
}
